package cn.itcast.quartz;

import cn.hutool.core.collection.CollectionUtil;
import cn.itcast.domain.cargo.Export;
import cn.itcast.domain.cargo.ExportExample;
import cn.itcast.service.cargo.ExportService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class ChangeExportResultJob {

    @Autowired
    private ExportService exportService;

    public void change() {
        // 1.从数据库中查找报运单状态为1这部分数据
        ExportExample exportExample = new ExportExample();
        exportExample.createCriteria().andStateEqualTo(1L);
        List<Export> list = exportService.findAll(exportExample);

        // 2.在通过webService调用海关平台，查询报运结果，更新数据库
        if (CollectionUtil.isNotEmpty(list)) {
            for (Export export : list) {
                exportService.changeExportEResult(export.getId());
            }
        }
    }
}
